Skip to content

Write an optional head-average safety factor into VOP files - #53

Merged
mcencini merged 1 commit into
mainfrom
claude/project-thread-ak6o9z
Nov 3, 2026
Merged

mcencini merged 1 commit into
mainfrom
claude/project-thread-ak6o9z

Conversation

@mcencini

@mcencini mcencini commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What this changes

vop.write and mariepy vops take an optional global_safety_factor (at least 1) together with its global_safety_basis line, and write both into the file's metadata. A file written without them carries neither key, so head-average SAR gets a factor of 1. PLAN.md's VOP-file table lists the two keys.

Why

pypulseqpp's check_sar (#215, 0.0.56) multiplies every head-average SAR by the file's global_safety_factor, the same way safety_factor multiplies local SAR. Until now mariepy could write only the local factor.

How it was verified

$ bash scripts/format_and_lint.sh
92 files left unchanged
All checks passed!
$ python -m pytest -q
829 passed, 347 skipped, 28 deselected, 15 warnings in 192.71s (0:03:12)

The 347 skips are the CUDA legs; this machine has no CUDA device.

New tests:

  • test_the_global_safety_factor_reads_back_and_is_absent_unless_given
  • test_a_global_safety_factor_below_one_is_refused
  • test_a_global_safety_factor_without_a_basis_is_refused
  • test_a_global_safety_basis_without_its_factor_is_refused
  • test_vops_writes_the_global_safety_factor_it_is_given

Checklist

  • bash scripts/format_and_lint.sh is clean
  • pytest -q passes, and new behaviour has a test whose name states the invariant it protects
  • Anything numerical is exercised on CPU and CUDA, or the CUDA leg is marked @pytest.mark.cuda and skips cleanly (the vop tests use the device fixture)
  • No comment or docstring describes the code's history

Generated by Claude Code

pypulseqpp reads global_safety_factor from a VOP file's metadata and
multiplies every head-average SAR by it. The writer and the vops command
take it with its basis line; a file without it gives head-average SAR a
factor of 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MFB6QLPkuY13FdsMg5RBpE
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mariepy/vop.py 0.00% 10 Missing ⚠️
src/mariepy/cli.py 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mcencini
mcencini merged commit 6b8320f into main Nov 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants